<?php

namespace News\Controller;
use Think\Controller;

/**
 * 消息页
 * Class IndexController
 * @package News\Controller
 */
class IndexController extends Controller {
    /**
     * 获取当前用户的消息列表
     * @param $token
     */
    public function getNewsList($token){
        $user_id = M('user')->field('id,flag,pid,create_time,status,remark,content')->where(['token'=>$token])->getField('userid');
        if(!$user_id){
            $this->ajaxReturn(['status'=>0]);
        }
        $news = M('news')->order('id desc')->where(['user_id'=>$user_id])->select();
        $this->ajaxReturn($news);
    }

    /**
     * 调用该接口实现消息已读
     * @param $id
     */
    public function newsStatusChange($id){
        M('news')->where(['id'=>$id])->setField(['status'=>1]);
    }

}